import com.jms.web.mapper.CardMapper;
import com.jms.web.mapper.TeaMapper;
import com.jms.web.pojo.Card;
import com.jms.web.pojo.Tea;
import com.jms.web.until.SqlSessionFactoryUntil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class test {
    @Test
    public void selectall()
    {
        SqlSession sqlSession = SqlSessionFactoryUntil.getSqlSession(true);
        TeaMapper teaMapper = sqlSession.getMapper(TeaMapper.class);

        List<Tea> list = teaMapper.selectAll();
        list.forEach(System.out::println);
    }
    @Test
    public void addall()
    {
        SqlSession sqlSession = SqlSessionFactoryUntil.getSqlSession(true);
        TeaMapper teaMapper = sqlSession.getMapper(TeaMapper.class);
        Tea tea = new Tea(111,"ss",2,2,"sd",1);
        Integer i = teaMapper.insert(tea);
        System.out.println(i);

    }
    @Test
    public void update()
    {
        SqlSession sqlSession = SqlSessionFactoryUntil.getSqlSession(true);
        TeaMapper teaMapper = sqlSession.getMapper(TeaMapper.class);
        Tea tea = new Tea(111,"s",2,2,"sd",1);
        Integer i = teaMapper.update(tea);
        System.out.println(i);

    }
    @Test
    public void delete()
    {
        SqlSession sqlSession = SqlSessionFactoryUntil.getSqlSession(true);
        TeaMapper teaMapper = sqlSession.getMapper(TeaMapper.class);
//        Tea tea = new Tea(111,"s",2,2,"sd",1);
        Integer i = teaMapper.delete(111);
        System.out.println(i);

    }
    @Test
    public void selectonetoner()
    {
        SqlSession sqlSession = SqlSessionFactoryUntil.getSqlSession(true);
        CardMapper cardMapper = sqlSession.getMapper(CardMapper.class);
        List<Card> list = cardMapper.selectAllCard();
        list.forEach(System.out::println);
    }

}
